package md.lanjing.com.module_wallet.contact;

import android.content.Context;

import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;
import com.lxh.baselibray.util.SPUtils;
import com.lxh.baselibray.util.ToastUtils;

;
import com.lxh.baselibray.constant.Constant;

import md.lanjing.com.module_wallet.api.WalletApiService;
import md.lanjing.com.module_wallet.bean.ChargeDrawRecordResponce;
import md.lanjing.com.module_wallet.bean.RecordRequest;
import retrofit2.Call;
import retrofit2.Response;

public class ChargeDrawRecordContact {
    public static class ChargeDrawRecordPresent extends BasePresent<IChargeDrawRecordView> {
        public void queryRecordList(final Context context, int pageNo, int type){
            WalletApiService service= ServiceGenerator.createService(WalletApiService.class);
            int userId= SPUtils.getInt(Constant.USER_ID,-1,context);
            RecordRequest request=new RecordRequest(userId,pageNo);
            Call<ChargeDrawRecordResponce> call=null;
            if (type==1){
                //充币
                call=service.chargeCoinRecord(request);

            }else if (type==2){
                //提币
                call = service.drawCoinRecord(request);
            }
            call.enqueue(new NetCallBack<ChargeDrawRecordResponce>() {
                @Override
                public void onSuccess(Call<ChargeDrawRecordResponce> call, Response<ChargeDrawRecordResponce> response) {
                    if (getView()!=null){
                        getView().getRecordListData(response);
                    }
                }

                @Override
                public void onFailed() {
                    ToastUtils.showLongToast(context,"网络请求异常");
                }
            });
        }
    }
    public interface IChargeDrawRecordView extends IBaseView {
        void getRecordListData(Response<ChargeDrawRecordResponce> response);
    }
}
